<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>ajax-axios</title>
</head>
<body>
<input type="button" value="获取数据get" id="btnGet">
<input type="button" value="删除数据post" id="btnPost">

<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>
    document.querySelector('#btnGet').addEventListener('click', function () {
        // axios({
        //     url: 'https://mock.apifox.cn/m1/3083103-0-default/emps/list',
        //     method: 'get',
        // }).then(result => {
        //     console.log(result.data.data)
        // }).cache(error => {
        //     console.log(error)
        // })
        axios.get(
            'https://mock.apifox.cn/m1/3083103-0-default/emps/list'
        ).then(result => {
            console.log(result.data.data)
        })
    })
    document.querySelector('#btnPost').addEventListener('click', function () {
        // axios({
        //     url: 'https://mock.apifox.cn/m1/3083103-0-default/emps/update',
        //     method: 'post',
        //     data: {
        //         id: 1
        //     }
        // }).then(result => {
        //     console.log(result.data)
        // }).cache(error => {
        //     console.log(error)
        // })
        axios.post(
            'https://mock.apifox.cn/m1/3083103-0-default/emps/update',
            {
                id: 1
            }
        ).then(result => {
            console.log(result.data)
        })
    })
</script>
</body>
</html>